<template>
	<uni-card>
		<uni-forms :modelValue="formData">
<!-- 			<uni-forms-item label="真实姓名" name="name" required>
				<uni-easyinput type="text" v-model="formData.name" placeholder="请输入真实姓名" />
			</uni-forms-item> -->
			<uni-forms-item label="用户名" name="name" required>
				<uni-easyinput type="text" v-model="formData.username" placeholder="请输入用户名" />
			</uni-forms-item>
<!-- 			<uni-forms-item label="邮箱" name="name" required>
				<uni-easyinput type="text" v-model="formData.name" placeholder="请输入邮箱" />
			</uni-forms-item>
			<uni-forms-item label="微信" name="name" required>
				<uni-easyinput type="text" v-model="formData.name" placeholder="请输入微信" />
			</uni-forms-item>
			<uni-forms-item label="QQ" name="name" required>
				<uni-easyinput type="text" v-model="formData.name" placeholder="请输入QQ" />
			</uni-forms-item>
			<uni-forms-item label="手机" name="name" required>
				<uni-easyinput type="text" v-model="formData.name" placeholder="请输入手机号" />
			</uni-forms-item> -->
		</uni-forms>
	</uni-card>
	<button @click="submitForm">提交</button>
</template>

<script lang="ts" setup>
	import {
		ref,onMounted,onBeforeMount
	} from 'vue'
	import api from '../../../api/api'
	const userInfo =ref()
	
	onBeforeMount(()=>{
		uni.getStorage({
			key:'userInfo',
			success:function(res){
				userInfo.value = res.data
				formData.value.username=userInfo.value.user.username
			}
		})

	})
	const formData = ref({
		name:'',
		username: '',
	})
	const submitForm = ()=>{
		api.user.update({
			userId:userInfo.value.user.userId,
			username:userInfo.value.user.username
		}).then(res=>{
			if(res.data.code==0){
				uni.showToast({
					'title':'修改成功'
				})
			}
		})
	}
</script>

<style>
</style>
